<template>
  <view>
    <view style="width: 92%;margin: 0 auto;">
      <!-- <view style="line-height: 100rpx;font-size: 30rpx;color: #333333;">
				{{xq.title || ''}}
      </view>-->
      <view style="overflow: hidden;">
        <u-parse :content="content"></u-parse>
        <!-- <RichText :nodes="content" />  -->
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      id: '',
      xq: {},
      content: '',
      index: ''
    }
  },
  onLoad(option) {
    this.id = option.id
    this.index = option.index
    this.xiang()
  },
  onPullDownRefresh() {
    this.xiang()

    setTimeout(function () {
      uni.stopPullDownRefresh();
    }, 1500);
  },
  // onShareAppMessage: function(e) {
  // 				// let title = '恭喜dog.东西获得成功'
  // 				let that=this
  // 				return {
  // 					title: this.xiang.title,
  // 					path:'/pages/my/wtxq?id='+that.id,
  // 					success:function(){
  // 						that.post('api/share/share','',true).then(res=>{
  // 							uni.showToast({
  // 								title: res.msg,
  // 								icon: "none",
  // 								duration: 1000
  // 							})
  // 						})
  // 					}
  // 				}
  // 			},
  methods: {
    xiang: function () {
      if (this.index == 1) {
        this.post('api/index/problem_info', { id: this.id }, true).then(res => {
          console.log(res)
          if (res.code == 1) {
            this.xq = res.data
            uni.setNavigationBarTitle({
              title: res.data.title
            });
            this.content = res.data.main_content.replace(/<img/gi, '<img class="rich-img" ')
              .replace(/<p/g, '<div')
              .replace(/\/p>/g, '\div>');
          }
        })
      } else if (this.index == 2) {
        this.post('api/index/help_info', { id: this.id }, true).then(res => {
          console.log(res)
          if (res.code == 1) {
            this.xq = res.data
            this.content = res.data.main_content.replace(/<img/gi, '<img class="rich-img" ')
              .replace(/<p/g, '<div')
              .replace(/\/p>/g, '\div>');
          }
        })
      }
    }
  }
}
</script>

<style lang="scss">
.rich-img {
  max-width: 100% !important;
  height: auto !important;
  // background-color: #FFFFFF;
}
page {
  background-color: #f5f5f5 !important;
  padding-top: 50rpx !important;
  font-family: Demibold;
}
</style>
